/*
 *    Copyright 2011-2012 The Hook Team
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.hook.yaksha.node;

import java.util.Map;

import org.hook.yaksha.config.MasterConfig;
import org.hook.yaksha.exception.AnalysisException;
import org.hook.yaksha.node.job.Job;

/**
 * 分析器Master获取任务集的管理接口
 * 
 * @author suwuqiang 2011-12-26
 */
public interface JobBuilder extends Component<MasterConfig> {

	/**
	 * 默认从config获得job编译路径
	 * 
	 * @return
	 * @throws AnalysisException
	 */
	public Map<String, Job> build() throws AnalysisException;

	/**
	 * 构建某一个Job的任务
	 * 
	 * @param job
	 * @throws AnalysisException
	 */
	public void buildTasks(Job job) throws AnalysisException;

	/**
	 * 从某一个位置获取任务集
	 * 
	 * @param 可以自己扩展是从本地文件载入还是http等其他方式载入
	 * @return
	 * @throws AnalysisException
	 */
	public Map<String, Job> build(String config) throws AnalysisException;

	/**
	 * 重新载入
	 * 
	 * @return
	 * @throws AnalysisException
	 */
	public Map<String, Job> rebuild() throws AnalysisException;

	/**
	 * 判断是否需要重新载入
	 * 
	 * @return
	 */
	public boolean isNeedRebuild();

	/**
	 * 设置重新载入
	 * 
	 * @param needRebuild
	 */
	public void setNeedRebuild(boolean needRebuild);
}
